<%@ include file="/WEB-INF/pages/common/taglibs.jsp" %>

<script type="text/javascript">
    function moreSummary() {
        submitForm("clientSummaryForm", "moreSummary.action");
    }

    function viewDetail(viewId,caseType){
       var currentForm = document.forms["clientSummaryForm"];
        currentForm.elements["viewId"].value = viewId;
        currentForm.elements["caseType"].value = caseType;
        currentForm.elements["fromInd"].value = "clientSummary";
        submitForm("clientSummaryForm", "viewDetail.action");
    }

    function removeLight(lightType,deptId){
         var currentForm = document.forms["clientSummaryForm"];
        currentForm.elements["lightType"].value = lightType;
        currentForm.elements["deptId"].value = deptId;
        if (window.confirm('<s:text name="label.confirm.close"/>')) {
                submitForm("clientSummaryForm", "removeLight.action");
            }
    }

    function addRecord(){
        submitForm("clientSummaryForm", "viewAddRecord.action");
    }

    function mianUser(){
        submitForm("clientSummaryForm", "../user/search.action");
    }

    function mianDept(){
       submitForm("clientSummaryForm", "../dept/search.action");
    }

      function submitReport(){
        submitForm("clientSummaryForm","../reports/initial.action");
    }

     function submitImageReport(){
        submitForm("clientSummaryForm","../reports/initialImage.action");
    }

    function manualAdd(){
       submitForm("clientSummaryForm","../cases/manual/viewAdd.action"); 
    }

    function downloadAttach(caseId,caseType){
        var currentForm = document.forms["clientSummaryForm"];
        currentForm.elements["downloadId"].value = caseId;
        currentForm.elements["downloadType"].value = caseType;
        submitForm("clientSummaryForm", "download.action");
    }

    function viewUploadAttach(){
       submitForm("clientSummaryForm", "viewUpload.action"); 
    }
</script>

<s:form name="clientSummaryForm">
    <s:hidden name="lightType"/>
    <s:hidden name="deptId"/>
    <s:hidden name="viewId"/>
    <s:hidden name="caseType"/>
    <s:hidden name="fromInd"/>
    <s:hidden name="downloadId"/>
    <s:hidden name="downloadType"/>     
    <table border="0" align="center" cellpadding="0" cellspacing="0" class="body_content dataTable full_width bordered">
        <tr class="section_title">
            <td class="section_title" align="left" colspan="2">
                <s:text name='label.client.light.title'/>
            </td>
        </tr>
        <tr>
            <th width="10%"><s:text name='label.client.light.title'/></th>
            <th width="90%"><s:text name='label.client.light.deptId'/></th>
        </tr>
        <s:set var="cIndex" value="0"/>
        <tr>
            <td align="center"><img src='<c:url value="/images/white.png"/>'></td>
            <td>
                <s:iterator id="wList" value="%{whiteList}" status="status">
                <s:property value="#wList.deptIdDesc"/>
                    <s:if test='#attr.user.userRole=="A"'>
                        <a href="javascript:removeLight('white','<s:property value="#wList.deptId"/>')">
                            <img src='<c:url value="/images/close.jpg"/>'>
                        </a>
                    </s:if>
                </s:iterator>
            </td>
        </tr>
        <tr>
            <td align="center"><img src='<c:url value="/images/blue.png"/>'></td>
            <td>
                <s:iterator id="bList" value="%{blueList}" status="status">
                <s:property value="#bList.deptIdDesc"/>
                    <s:if test='#attr.user.userRole=="A"'>
                    <a href="javascript:removeLight('blue','<s:property value="#bList.deptId"/>')">
                        <img src='<c:url value="/images/close.jpg"/>'>
                    </a>
                    </s:if>
                </s:iterator>
                <s:if test='#attr.user.userRole!="A"'>
                     <s:iterator id="bAttach" value="%{bAttachList}" status="status">
                        <a href="javascript:downloadAttach('<s:property value="#bAttach.caseId"/>','<s:property value="#bAttach.caseType"/>')">
                            <s:property value="#bAttach.fileName"/>
                        </a>
                         &nbsp;&nbsp;
                     </s:iterator>
                </s:if>
            </td>
        </tr>
        <tr>
            <td align="center"><img src='<c:url value="/images/purple.png"/>'></td>
            <td>
                <s:iterator id="pList" value="%{purpleList}" status="status">
                    <s:property value="#pList.deptIdDesc"/>
                    <s:if test='#attr.user.userRole=="A"'>
                    <a href="javascript:removeLight('purple','<s:property value="#pList.deptId"/>')">
                        <img src='<c:url value="/images/close.jpg"/>'>
                    </a>
                    </s:if>
                </s:iterator>
                <s:if test='#attr.user.userRole!="A"'>
                     <s:iterator id="pAttach" value="%{pAttachList}" status="status">
                        <a href="javascript:downloadAttach('<s:property value="#pAttach.caseId"/>','<s:property value="#pAttach.caseType"/>')">
                            <s:property value="#pAttach.fileName"/>
                        </a>
                         &nbsp;&nbsp;
                     </s:iterator>
                </s:if>
            </td>
        </tr>
        <tr>
             <td align="center"><img src='<c:url value="/images/yellow.png"/>'></td>
            <td>
                <s:iterator id="yList" value="%{yellowList}" status="status">
                <s:property value="#yList.deptIdDesc"/>
                    <s:if test='#attr.user.userRole=="A"'>
                        <a href="javascript:removeLight('yellow','<s:property value="#yList.deptId"/>')">
                            <img src='<c:url value="/images/close.jpg"/>'>
                        </a>
                    </s:if>
                </s:iterator>
                <s:if test='#attr.user.userRole!="A"'>
                    <s:iterator id="yAttach" value="%{yAttachList}">
                        <a href="javascript:downloadAttach('<s:property value="#yAttach.caseId"/>','<s:property value="#yAttach.caseType"/>')">
                            <s:property value="#yAttach.fileName"/>
                        </a>
                         &nbsp;&nbsp;
                    </s:iterator>
                </s:if>                
            </td>
        </tr>
        <tr>
            <td align="center"><img src='<c:url value="/images/red.png"/>'></td>
                <td>
                    <s:iterator id="rList" value="%{redList}" status="status">
                        <s:property value="#rList.deptIdDesc"/>
                        <s:if test='#attr.user.userRole=="A"'>
                        <a href="javascript:removeLight('red','<s:property value="#rList.deptId"/>')">
                            <img src='<c:url value="/images/close.jpg"/>'>
                        </a>
                        </s:if>
                    </s:iterator>
                    <s:if test='#attr.user.userRole!="A"'>
                             <s:iterator id="rAttach" value="%{rAttachList}" status="status">
                                <a href="javascript:downloadAttach('<s:property value="#rAttach.caseId"/>','<s:property value="#rAttach.caseType"/>')">
                                    <s:property value="#rAttach.fileName"/>
                                </a>
                                 &nbsp;&nbsp;
                             </s:iterator>
                    </s:if>           
             </td>
         </tr>
    </table>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="body_content full_width bordered">
        <tr class="section_title">
            <td class="section_title" align="left">
                <s:text name='label.client.summary.title'/>
            </td>
            <td class="section_title" align="right"><s:a href="javascript:moreSummary();"><s:text name='label.client.more'/></s:a></td>
        </tr>
        <s:iterator id="cList" value="%{List}" status="status">
            <s:if test="#status.even">
                <tr class="even">
            </s:if>
            <s:if test="#status.odd">
                <tr class="odd">
            </s:if>
            <td align="left" width="80%" colspan="2"  cellspacing="0">
                <li/>
                <a href="javascript:viewDetail('<s:property value="#cList.viewId"/>','<s:property value="#cList.caseType"/>')">
                    <s:if test='#cList.caseType=="six"'>
                                [<s:text name="label.case.select.title6"/>]
                            </s:if>
                            <s:if test='#cList.caseType=="seven"'>
                                [<s:text name="label.case.select.title7"/>]
                            </s:if>
                            <s:if test='#cList.caseType=="eight"'>
                                [<s:text name="label.case.select.title8"/>]
                            </s:if>
                            <s:if test='#cList.caseType=="nine"'>
                                [<s:text name="label.case.select.title9"/>]
                            </s:if>
                            <s:if test='#cList.caseType=="ten"'>
                                [<s:text name="label.case.select.title10"/>]
                            </s:if>
                    <s:property value="#cList.title"/>
                </a>
                &nbsp;
                <font size="2%">[<s:property value="#cList.createDt"/>]</font>
            </td>
            </tr>
        </s:iterator>
    </table>    

    <br>
     <table class="sectionBorder" width="100%">
            <tr>
                <td class="txtData">
                    <input type="button" class="button" value="<s:text name='label.add.record'/>" onclick="addRecord();">
                    <input type="button" class="button" value="<s:text name='label.feedback.maintain'/>" onclick="viewUploadAttach();">
<s:if test='#attr.user.userRole=="A"'>
&nbsp;
                    <input type="button" class="button" value="<s:text name='label.user.main'/>" onclick="mianUser();">
&nbsp;
                    <input type="button" class="button" value="<s:text name='label.dept.main'/>" onclick="mianDept();">
                    <input type="button" class="button" value="<s:text name='label.report'/>" onclick="submitReport();">
                    <input type="button" class="button" value="<s:text name='label.imgreport'/>" onclick="submitImageReport();">
                    <input type="button" class="button" value="<s:text name='label.title.manualadd'/>" onclick="manualAdd();">
</s:if>
                </td>
            </tr>
    </table>
</s:form>